import { createApp } from 'vue';
import App from './App.vue';
import 'babel-polyfill';
import * as ElIconModules from '@element-plus/icons-vue';

/* element-plus ui框架全局引入 */
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import 'element-plus/dist/index.css';

/* 自定义样式 */
import '@/assets/css/main.less';

/* 极验 */
require('@/assets/js/gt');

// 引入路由
import router from './router/index';

// 引入状态管理
import { createPinia } from 'pinia';
import piniaPersist from 'pinia-plugin-persist';
const pinia = createPinia();
pinia.use(piniaPersist);

// 引用API文件
import api from './utils/request.js';

/* 自定义方法类 */
import commonFun from '@/utils/common.js';

/* 自定义toast */
import '@/components/Toast/index.css';
import { toast } from '@/components/Toast/index';

const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
app.use(router);
app.use(pinia);

app.config.globalProperties.$api = api;
app.config.globalProperties.$commonFun = commonFun;
app.config.globalProperties.$toast = toast;
Object.keys(ElIconModules).forEach(function (key) {
  app.component(ElIconModules[key].name, ElIconModules[key]);
});

app.mount('#app');
